/**
 * Created by hps on 17-4-27.
 */
public class ArrayInObj {
    private Person[] a;
    private int nElems;

    public ArrayInObj(int max) {
        a = new Person[max];
        nElems = 0;
    }

    public void insert(Person person) {
        a[nElems++] = person;
    }

    public void display() {
        for(int i = 0; i < nElems; i++)
            a[i].displayPerson();
    }

    public void insertionSort() {
        for(int i = 1; i < nElems; i++) {
            Person temp = a[i];
            int j = i;
            while (j > 0 && a[j - 1].getLastName().compareTo(temp.getLastName()) > 0) {
                a[j] = a[j - 1];
                j--;
            }
            a[j] = temp;
        }
    }
}
